package com.framework.controller.newcontroller;

import com.framework.entity.flow.FlowAccount;
import com.framework.entity.flow.FlowTask;
import com.framework.exception.util.RespResult;
import com.framework.service.*;
import com.framework.view.FlowAccountView;
import com.framework.view.SeparatMonthView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 功能描述: 流水控制器
 *
 * @author wq
 * @date 2018/9/26 20:32
 */
@RestController
@Api(value = "流水查询模块", tags = {"流水查询模块"})
@RequestMapping(value = "new/flow")
public class NewFlowController {

    @Autowired
    private FlowAccountService flowAccountService;
    @Autowired
    private FlowActivService flowActivService;
    @Autowired
    private FlowTaskService flowTaskService;
    @Autowired
    private FlowFrozenTerminalService flowFrozenTerminalService;

    /**
     * 获取近期6个月收益总明细
     *
     * @param token 当前人登录token
     * @return
     */
    @GetMapping("user/queryMonthProfitSumList")
    @ApiOperation("获取近期6个月收益总明细")
    public RespResult queryMonthProfitSumList(String token) {
        Map<String, Object> map = flowAccountService.queryMonthProfitSumList(token);
        return RespResult.ok(map);
    }

    /**
     * 获取账户支出明细
     *
     * @param token       当前人登录token
     * @param flowAccount 对象
     * @param pageNo      页码
     * @return
     */
    @GetMapping("user/queryFlowAccountList")
    @ApiOperation("获取账户支出明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNo", value = "页码", dataType = "int", paramType = "query", required = true)})
    public RespResult queryFlowAccountList(String token, FlowAccount flowAccount, Integer pageNo) {
        List<FlowAccount> list = flowAccountService.queryFlowAccountList(token, flowAccount, pageNo);
        return RespResult.ok().put("flowList", list);
    }

    /**
     * 激活返现明细
     *
     * @param token
     * @return
     */
    @GetMapping("user/queryActivInfoList")
    @ApiOperation("激活返现")
    public RespResult queryActivInfoList(String token) {
        List<SeparatMonthView> list = flowActivService.queryActivInfoList(token);
        return RespResult.ok().put("list", list);
    }
    /**
     * 提现明细
     *
     * @param token
     * @param pageNo
     * @return
     */
    @GetMapping("user/queryFlowTaskList")
    @ApiOperation("提现流水")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNo", value = "页码", dataType = "int", paramType = "query", required = true)
    })
    public RespResult queryFlowTaskList(String token, Integer pageNo) {
        List<FlowTask> list = flowTaskService.queryTakeList(token, pageNo);
        return RespResult.ok().put("list", list);
    }

    /**
     * 收益明细 图表统计
     * @param token
     * @param type
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("user/queryFlowAccountTable")
    @ApiOperation("收益明细 图表统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "登录产生的token", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "type", value = "类型 1：日 2周 3月", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "时间筛选区间的开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "时间筛选区间的开结束时间", dataType = "String", paramType = "query")
    })
    public RespResult queryFlowAccountTable(String token, Integer type, String startDate,String endDate) {
        List<Map<String, Object>> list = flowAccountService.queryFlowAccountTable(token, type, startDate, endDate);
        return RespResult.ok().put("list",list);
    }

    /**
     * 收益明细
     *
     * @param token
     * @param pageNo
     * @return
     */
    @GetMapping("user/queryIncomeInfo")
    @ApiOperation("收益明细 总接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "登录产生的token", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "pageNo", value = "页码", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "incomeType", value = "收益类型 1：自营 2：团队 3激活 4其他", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "dateType", value = "时间类型 1 当月 2总计 3 时间筛选", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query", required = false),
            @ApiImplicitParam(name = "endDate", value = "结束时间", dataType = "string", paramType = "query", required = false),
    })
    public RespResult queryIncomeInfo(String token, Integer pageNo,Integer incomeType,Integer dateType,String startDate,String endDate) {
        Map<String,Object> map= flowAccountService.queryIncomeInfo(token, pageNo,incomeType,dateType,startDate,endDate);
        return RespResult.ok().put("data", map);
    }

    /**
     * 收益明细 收益支出总计
     *
     * @param token
     * @param dateType
     * @return
     */
    @GetMapping("user/queryIncomeAndExpend")
    @ApiOperation("收益明细 收益支出总计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "登录产生的token", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "dateType", value = "时间类型 1 当月 2总计 3 时间筛选", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query", required = false),
            @ApiImplicitParam(name = "endDate", value = "结束时间", dataType = "string", paramType = "query", required = false),
    })
    public RespResult queryIncomeAndExpend(String token ,Integer dateType,String startDate,String endDate) {
        Map<String,Object> map= flowAccountService.queryIncomeAndExpend(token,dateType,startDate,endDate);
        return RespResult.ok().put("data", map);
    }
    /**
     * 收益明细 底部列表
     *
     * @param token
     * @param pageNo
     * @return
     */
    @GetMapping("user/queryIncomeList")
    @ApiOperation("收益明细 底部列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "登录产生的token", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "pageNo", value = "页码", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "dateType", value = "时间类型 1 当月 2总计 3 时间筛选", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query", required = false),
            @ApiImplicitParam(name = "endDate", value = "结束时间", dataType = "string", paramType = "query", required = false),
    })
    public RespResult queryIncomeList(String token, Integer pageNo,Integer incomeType,Integer dateType,String startDate,String endDate) {
        Map<String,Object> map= flowAccountService.queryIncomeList(token, pageNo,dateType,incomeType, startDate,endDate);
        return RespResult.ok().put("data", map);
    }

    /**
     * 通联查询冻结详情
     *
     * @param token
     * @return
     */
    @GetMapping("user/queryFrozenDetail")
    @ApiOperation("通联查询冻结详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "登录产生的token", dataType = "string", paramType = "query", required = true),
    })
    public RespResult queryFrozenDetail(String token) {
        Map<String,Object> map= flowFrozenTerminalService.queryFrozenDetail(token);
        return RespResult.ok().put("data", map);
    }



}
